package cn.lysj.framework.coupon.repository;

import cn.lysj.framework.base.BaseRepository;
import cn.lysj.framework.coupon.domain.Coupon;
import cn.lysj.framework.coupon.vo.BirthdayCouponToStoreVo;
import cn.lysj.framework.coupon.vo.NewVipCouponToStoreVo;
import cn.lysj.framework.coupon.vo.SelectCouponVo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @author zwj
 * @description 优惠券数据处理层
 * @create 2019-01-16 09:38:37
 **/
public interface CouponRepository extends BaseRepository<Coupon> {

    @Query("select new cn.lysj.framework.coupon.vo.SelectCouponVo(a.id,a.name,a.storeId, a.fullReductionMoney, a.discountMoney, a.shareType, a.share, a.validPeriod) " +
            "from Coupon a where a.id not in ?1 and a.storeId = ?2 and a.delFlag = ?3 and a.deadlineType = ?4 order by a.updateTime desc ")
    List<SelectCouponVo> findSelectCouponVoToUseConfig(String[] couponId, String storeId, Integer delFlag, Integer deadlineType);

    @Query("select new cn.lysj.framework.coupon.vo.SelectCouponVo(a.id,a.name,a.storeId, a.fullReductionMoney, a.discountMoney, a.shareType, a.share, a.validPeriod) " +
            "from Coupon a where  a.storeId = ?1 and a.delFlag = ?2 and a.deadlineType = ?3 order by a.updateTime desc ")
    List<SelectCouponVo> findSelectCouponVoToUseConfig( String storeId, Integer delFlag, Integer deadlineType);


    Coupon findByStoreIdAndDelFlagAndId(String storeId,Integer delFlag,String couponId);

    Coupon findByIdAndDelFlag(String couponId,Integer delFlag);





}
